package com.wan37.logic.shop.service.impl;

import com.wan37.logic.shop.dao.ShopDao;
import com.wan37.logic.shop.domain.entity.ShopDO;
import com.wan37.logic.shop.domain.vo.CommodityConfigVO;
import com.wan37.logic.shop.domain.vo.ShopVO;
import com.wan37.logic.shop.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

/**
 * @author : luoyong
 * @date : 2020-07-06 10:17
 **/
@Service("shopService")
public class ShopServiceImpl implements ShopService {
    @Autowired
    private ShopDao shopDao;
    @Override
    public List<ShopVO> findShopByShopId(String shopId) {
        List<ShopDO> shopDOList = shopDao.findShopByShopId(shopId);
        if (shopDOList == null || shopDOList.size() == 0){
            return null;
        }
        List<ShopVO> shopVOList = new LinkedList<>();
        for (ShopDO shopDO :shopDOList){
            shopVOList.add(new ShopVO(shopDO));
        }
        return shopVOList;
    }

    @Override
    public List<ShopVO> getAll() {
        List<ShopDO> shopDOList = shopDao.getAll();
        if (shopDOList == null || shopDOList.size() == 0){
            return null;
        }
        List<ShopVO> shopVOList = new LinkedList<>();
        for (ShopDO shopDO : shopDOList){
            shopVOList.add(new ShopVO(shopDO));
        }
        return shopVOList;
    }

    @Override
    public boolean update(ShopVO shopVO) {
        return shopDao.update(new ShopDO(shopVO));
    }

    @Override
    public boolean save(ShopVO shopVO) {
        return shopDao.add(new ShopDO(shopVO));
    }

    @Override
    public boolean delete(ShopVO shopVO) {
        return false;
    }
}
